package gtug.duesseldorf.client.model;

import java.io.Serializable;

/**
 * 
 * 
 * @author Georg Sendt
 */
public class ClientWaveId implements Serializable {

	private static final long serialVersionUID = 1L;
	private String m_id;
	private String m_name;
	private String m_digest;

	/**
	 * private constructor for serialization
	 */
	@SuppressWarnings("unused")
	private ClientWaveId() {
	}

	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("ClientWaveId: [").append(m_id).append(", ").append(m_name)
				.append(", ").append(m_digest).append("]");

		return buf.toString();
	}

	public ClientWaveId(String id) {
		this(id, null, null);
	}

	public ClientWaveId(String id, String name, String digest) {
		m_id = id;
		m_name = name;
		m_digest = digest;
	}

	public String getId() {
		return m_id;
	}

	public String getName() {
		return m_name;
	}

	public String getDigest() {
		return m_digest;
	}

	/**
	 * concatinate name and digest
	 * 
	 * @return
	 */
	public String getNameAndDigest() {
		return m_name + ": " + m_digest;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((m_id == null) ? 0 : m_id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ClientWaveId other = (ClientWaveId) obj;
		if (m_id == null) {
			if (other.m_id != null)
				return false;
		} else if (!m_id.equals(other.m_id))
			return false;
		return true;
	}

}
